project(VMTK_TESTING)

set(VMTK_TESTING_INIT_SRC
  __init__.py
  )

if(NOT VMTK_TESTING_INSTALL_LIB_DIR)
  set(VMTK_TESTING_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/tests)
endif(NOT VMTK_TESTING_INSTALL_LIB_DIR)

foreach (SCRIPT_FILE ${VMTK_TESTING_INIT_SRC})
  configure_file(${VMTK_TESTING_SOURCE_DIR}/${SCRIPT_FILE} ${VMTK_TESTING_INSTALL_LIB_DIR}/${SCRIPT_FILE} COPYONLY)
endforeach (SCRIPT_FILE)

execute_process(COMMAND git submodule update --init -- ${VMTK_TESTING_SOURCE_DIR}/vmtk-test-data
                WORKING_DIRECTORY ${VMTK_TESTING_SOURCE_DIR})

if(NOT VMTK_TESTING_DATA_INSTALL_LIB_DIR)
  set(VMTK_TESTING_DATA_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/tests)
endif(NOT VMTK_TESTING_DATA_INSTALL_LIB_DIR)

file(COPY ${VMTK_TESTING_SOURCE_DIR}/vmtk-test-data
    DESTINATION ${VMTK_TESTING_DATA_INSTALL_LIB_DIR})


set(VMTK_TESTING_DIRECTORIES
  test_PypeS
  test_vmtkScripts
  )

foreach (TEST_DIR ${VMTK_TESTING_DIRECTORIES})
  add_subdirectory(${TEST_DIR})
endforeach (TEST_DIR)